<template>
	<view class="status-bar"></view>
	<view class="">
		<uni-swipe-action>
			<nodata v-if="isdata"></nodata>
			<uni-swipe-action-item
				:right-options="options"
				:show="isOpened"
				@change="change"
				@click="bindClick(item,index)"
				v-for="(item,index) in info" :key="index"
			>
			<view class="border-bEDEDED pb30 mt30 mr30 ml30">
				<view class="flex-ju-b posire">
					<view>
						<view class="flex-a-i">
							<image class="image wh76-76 ra76 mr20" :src="item.user.avatar?item.user.avatar:'/static/mo.png'"></image>
							<view>
								<view class="size29">{{item.user.nickname}}</view>
								<view class="size22 color999 mt5">{{item.result}}</view>
							</view>
						</view>
					</view>
					<!-- <view>
						<image class="image wh76-76 " src="../../static/aaa.png"></image>
					</view> -->
				</view>
			</view>
			</uni-swipe-action-item>
			 
			
			
		</uni-swipe-action>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isdata:false,
				info:[],
				page:1,
				isOpened:"",
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#FF3B30'
						}
					}
				],
			}
		},
		onLoad() {
			this.getlist()
		},
		onReachBottom() {
			this.page++
			this.getlist()
		},
		methods: {
			bindClick(item,index){
				this.http('/api/del_msg/'+item.id,{},'DELETE').then(res=>{
					uni.showToast({
						title:"删除成功",
						icon:"none"
					})
					this.isOpened = "none"
					this.info.splice(index,1)
					if(this.info.length){
						this.isdata=false
					}else{
						this.isdata=true
					}
				})
			},
			getlist(){
				this.http('/api/msg_list',{type:1,page:this.page,limit:20}).then(res=>{
					this.info = [...this.info,...res.data.list]
					if(this.info.length){
						this.isdata=false
					}else{
						this.isdata=true
					}
					var buser = uni.getStorageSync('user')
					buser.like_un_read=0
					uni.setStorageSync('user',buser)
				})
			},
			change(e){
				console.log(e)
				this.isOpened = ""
			},
		}
	}
</script>

<style>

</style>
